package com.exam.meituan;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * date:
 * description:
 */
public class Solution003 {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String line1 = bufferedReader.readLine();
        String[] str1 = line1.trim().split(" ");
        int n = Integer.parseInt(str1[0]);
        int m = Integer.parseInt(str1[1]);
        char[] dirs = new char[m];
        String line2 = bufferedReader.readLine();
        String[] str2 = line2.trim().split(" ");
        for (int i = 0; i < m; i++) {
            dirs[i] = str2[i].charAt(0);
        }
        int[] dist = new int[m];
        String line3 = bufferedReader.readLine();
        String[] str3 = line3.trim().split(" ");
        for (int i = 0; i < m; i++) {
            dist[i] = Integer.parseInt(str3[i]);
        }
        List<Integer> xcut = new ArrayList<>();
        xcut.add(0);
        xcut.add(n);
        List<Integer> ycut = new ArrayList<>();
        ycut.add(0);
        ycut.add(n);
        List<Integer> zcut = new ArrayList<>();
        zcut.add(0);
        zcut.add(n);
        int X =n, Y = n, Z = n;
        for (int i = 0; i < m; i++) {
            if(dirs[i] == 'x'){
                xcut.add(dist[i]);
                X = findMax(xcut);
                System.out.println(X * Y * Z);
            }else if(dirs[i] == 'y'){
                ycut.add(dist[i]);
                Y = findMax(ycut);
                System.out.println(X * Y * Z);
            }else if(dirs[i] == 'z'){
                zcut.add(dist[i]);
                Z = findMax(zcut);
                System.out.println(X * Y * Z);
            }
        }
    }

    public static int findMax(List<Integer> cut) {
        Collections.sort(cut);
        int res = 0;
        for (int i = 1; i < cut.size(); i++) {
            res = Math.max(res, cut.get(i) - cut.get(i - 1));
        }
        return res;
    }
}
